package com.comunity_cloud.client.view2;

import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.filechooser.FileSystemView;

public class FileSystemUtils {

	public static String getFileTypeDesc(File file) {
		return FileSystemView.getFileSystemView().getSystemTypeDescription(file);
	}
	
	public static ImageIcon getFileIcon(File file){
		
		return (ImageIcon)FileSystemView.getFileSystemView().getSystemIcon(file);
		
	}
	
	public static byte[] getFileImage(File file) throws IOException{
		
		BufferedImage image = ((BufferedImage)((ImageIcon)FileSystemView.getFileSystemView().getSystemIcon(file)).getImage());
		ByteArrayOutputStream bos = new ByteArrayOutputStream();
		ImageIO.write(image, "png", bos );
		return bos.toByteArray();		
	}
}
